/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.db.NoteManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListNotes extends AbstractAction
/*    */ {
/* 25 */   private static Logger logger = Logger.getLogger(ListNotes.class.getName());
/*    */ 
/*    */   public ListNotes(AbstractHttpServlet servlet) {
/* 28 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException
/*    */   {
/* 35 */     String subjectIds = Util.getURLParameter(request
/* 36 */       .getParameter("subjectIds"));
/* 37 */     int dealId = Util.getURLIntParameter(request.getParameter("dealId"));
/* 38 */     int offset = Util.getURLIntParameter(request.getParameter("offset"));
/*    */ 
/* 40 */     NoteManager manager = new NoteManager();
/*    */     try {
/* 42 */       List result = null;
/* 43 */       if (dealId > 0) {
/* 44 */         result = manager.listDealNotes(dealId, false);
/*    */       }
/* 46 */       else if (offset > 0) {
/* 47 */         result = manager.listCustomerNotes(subjectIds, offset, 5);
/*    */       }
/*    */       else {
/* 50 */         result = manager.listCustomerNotes(subjectIds, -1, 0);
/*    */       }
/*    */ 
/* 53 */       response.setContentType("text/html;charset=utf-8");
/* 54 */       PrintWriter out = response.getWriter();
/* 55 */       JSONObject jsonObject = new JSONObject();
/* 56 */       jsonObject.put("error", "0");
/* 57 */       jsonObject.put("notes", result);
/* 58 */       out.println(jsonObject);
/* 59 */       out.flush();
/* 60 */       out.close();
/* 61 */       return;
/*    */     } catch (DBException e) {
/* 63 */       logger.warn("load customer note failed", e);
/*    */     } catch (SQLException e) {
/* 65 */       logger.warn("load customer note failed", e);
/*    */     }
/*    */ 
/* 68 */     showErrorMessage(response, "备注信息加载失败");
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListNotes
 * JD-Core Version:    0.6.1
 */